
# server_link = raw_input('JIRA Link: ')
# user_name = raw_input('User Name: ')
# passcode = raw_input('Password: ')

import os
from openpyxl import Workbook
from jira import JIRA
jira_options = {
    'server': 'https://jiradc.ext.net.nokia.com',
    'verify': False
    }

jira = JIRA(jira_options, auth=('linhu', 'Hlf0312@'))
fields = jira.fields()
wb = Workbook()
sheet = wb.active
sheet.title = 'JIRA Field Mapping'
row = 1
sheet.cell(row=row, column=1).value = 'JIRA UI'
sheet.cell(row=row, column=2).value = 'Rest API'
sheet.cell(row=row, column=3).value = 'Type'
row += 1
for field in fields:
    # print(field)
    sheet.cell(row=row, column=1).value = field['name']
    sheet.cell(row=row, column=2).value = field['id']
    if 'schema' in fields:
        sheet.cell(row=row, column=3).value = field['schema']['type']
    row += 1
wb.save(os.path.join(os.getcwd(), 'JIRA Field Mapping.xlsx'))
print(os.getcwd(), 'File Stored!')


